<template>
  <div class="name">
    <h2>{{ name }}</h2>
    <div>{{ nickName }}</div>
    <a-button type="primary" @click="change1">子组件</a-button>
  </div>
</template>

<script setup>
import { inject } from 'vue'
import { useStore } from 'vuex'
// 接收props,并返回一个对象，可以在js中使用props来获取传入的数据
const props = defineProps({
  name: {
    type: String,
    default: 'zs'
  }
})
let nickName = inject('nickName')
const store = useStore()
const emit = defineEmits(['changeName'])
const change1 = () => emit('changeName')
</script>

<style scoped lang="less"></style>
